package com.pacific.sign.biz.wrapper.aop;

import java.util.UUID;

/**
 * 线程上下文相关的数据工具类型<br/>
 *
 */
public class ThreadLocalUtils {

    //当前线程的UUID信息，主要用于打印日志；
    private static ThreadLocal<String> currLogUuid = new InheritableThreadLocal<String>() {
        @Override
        protected String initialValue() {
            return UUID.randomUUID().toString()/*.toUpperCase()*/;
        }
    };

    public static void clear() {
            currLogUuid.remove();
    }

    public static String getCurrLogUuid() {
        return currLogUuid.get();
    }

    public static String getLogPrefix() {
    	if(getCurrLogUuid() ==null){
    		return "";
    	}
        return "<uuid=" + getCurrLogUuid() + ">";
    }

    public static void initialize() {
        currLogUuid.set(UUID.randomUUID().toString());
    }
}
